package com.example.servlet;

import com.example.entity.IndexInfo;
import com.example.entity.Resource;
import com.example.entity.User;
import com.example.service.UserService;
import com.example.utils.BaseDao;
import com.example.utils.BaseServlet;
import com.example.utils.ResultData;
import com.example.vo.IndexInfoDto;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/user")
public class UserServlet extends BaseServlet {
    UserService userService=new UserService();
    @Override
    public Class getChildClass() {
        return this.getClass();
    }
    public ResultData login(HttpServletRequest request,HttpServletResponse response){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        User user=new User();
        user.setUsername(username);
        user.setPassword(password);
        ResultData resultData = userService.login(user);
        if(resultData.getCode()==200){
            HttpSession session = request.getSession();
            session.setAttribute("user",user);
        }
        return resultData;
    }

}
